package com.android.lib.base.network.error

import com.blankj.utilcode.util.ToastUtils
import kotlinx.coroutines.CoroutineExceptionHandler


object BaseError {

    private val defNetException = CoroutineExceptionHandler { _, throwable ->
        val exception = ExceptionHandle.handleException(throwable)
        ToastUtils.showShort(exception.code.toString())
    }

    val netException: CoroutineExceptionHandler
        get() = customException ?: defNetException


    private var customException: CoroutineExceptionHandler? = null


    fun setBaseException(baseException: CoroutineExceptionHandler) = apply {
        customException = baseException
    }

}